<% extends 'layout.html' %>

<% block content %>

<div class="wrap mailpoet-about-wrap">
  <h1><%= __('Greetings, humans.') %></h1>

  <p class="about-text"><%= __('Thanks for using MailPoet! We really appreciate all of your love, affection, [link]and (good) plugin reviews.[/link]')
    |replaceLinkTags('https://wordpress.org/support/plugin/wysija-newsletters/reviews/', {'target' : '_blank'})
    |raw
    %>
  </p>
  <div class="mailpoet-logo"><img src="<%= image_url('welcome_template/mailpoet-logo.png') %>" alt="MailPoet Logo" /></div>

  <h2 class="nav-tab-wrapper wp-clearfix">
    <a href="admin.php?page=mailpoet-welcome" class="nav-tab"><%= __('Welcome') %></a>
    <a href="admin.php?page=mailpoet-update" class="nav-tab nav-tab-active"><%= __("What's New") %></a>
  </h2>

  <div id="mailpoet-changelog" class="feature-section one-col">
    <h2 class="mailpoet-feature-top"><%= __('List of Changes') %></h2>
    <% if changelog %>
      <% for item in changelog %>
        <h3><%= item.version %></h3>
        <ul>
          <% for change in item.changes %>
            <li><%= change %></li>
          <% endfor %>
        </ul>
      <% endfor %>
    <% else %>
      <p style="text-align: center"><%= __('See readme.txt for a changelog.') %></p>
    <% endif %>
    <a class="button button-secondary" href="https://wordpress.org/plugins/mailpoet/#developers" target="_blank"><%= __('View all changes') %> &rarr;</a>
  </div>

  <hr>

  <% if(not settings.analytics.enabled) %>
    <div class="feature-section one-col mailpoet_centered">
      <h2><%= __('Do Your Part to Make MailPoet Better') %></h2>
      <div class="lead-description">

        <label>
          <input type="checkbox" id="mailpoet_analytics_enabled" value="1">&nbsp;
          <%= __('Yes, share my data anonymously.') %>
        </label>
      </div>
      <p class="top-space-triple"><%= __("By sharing your data with us, you can help us understand what our users like (and don't like).") %>
        <%= __('We use it to prioritize and develop new plugin features.') %><br>
        <%= __('Share your data to help shape the future of MailPoet! [link]Read more.[/link]')
          |replaceLinkTags('http://beta.docs.mailpoet.com/article/130-sharing-your-data-with-us', {'target' : '_blank'})
          |raw
          %>
    </div>

    <hr>
  <% endif %>

  <div class="feature-section one-col mailpoet_centered">
    <h2><%= __('Care to Give Your Opinion?') %></h2>

    <script type="text/javascript" charset="utf-8" src="//secure.polldaddy.com/p/9801037.js"></script>
    <noscript><a href="//polldaddy.com/poll/9801037/">Did you install MailPoet yourself?</a></noscript>
  </div>

  <hr>

  <div class="feature-section one-col mailpoet_centered">
    <a class="button button-primary go-to-plugin" href="admin.php?page=mailpoet-newsletters"><%= __('Awesome! Now, take me to MailPoet') %> &rarr;</a>
  </div>

</div>

<script type="text/javascript">
  jQuery(function($) {
    $(function() {
      MailPoet.trackEvent(
        'User has updated MailPoet',
        {'MailPoet Free version': window.mailpoet_version}
      );
    });
    $('#mailpoet_analytics_enabled').on('click', function() {
      var is_enabled = $(this).is(':checked') ? true : '';
      MailPoet.Ajax.post({
        api_version: window.mailpoet_api_version,
        endpoint: 'settings',
        action: 'set',
        data: {
          analytics: { enabled: (is_enabled)}
        }
      }).fail((response) => {
        if (response.errors.length > 0) {
          MailPoet.Notice.error(
            response.errors.map((error) => { return error.message; }),
            { scroll: true }
          );
        }
      });
    })
  });

</script>
<% endblock %>
